package com.zhn.usermanager.poi;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

import java.io.FileOutputStream;
import java.io.IOException;

public class POICreate {
    //文件存放路径
    public static String outputFile = "E:\\idea_workspace\\j259_ssm_user\\src\\main\\java\\com\\zhn\\usermanager\\poi\\test01.xls";

    public static void main(String[] args) throws IOException {
        HSSFWorkbook workbook = new HSSFWorkbook();                          //创建Excel对象
        HSSFSheet sheet = workbook.createSheet("第一页");        // 创建一个sheet对象
        HSSFRow row = sheet.createRow(0);                            // 根据下标指定某一行，行数从0开始，例如  0代表第一行
        HSSFCell cell = row.createCell(0);                            // 根据下标指定某一行，列数从0开始，例如  0代表第一列
        cell.setCellValue("第一行第一列");
        cell = row.createCell(1);
        cell.setCellValue("第一行第二列");

        FileOutputStream fOS = new FileOutputStream(outputFile);              //创建文件输出流
        workbook.write(fOS);
        fOS.flush();
        fOS.close();
    }
}
